<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 寄生式组合方式继承
        function Person(name) {
            this.name = name
        }
        Person.prototype.sayName = function() {
            console.log(this.name);
        }

        function Student(name, score) {
            Person.call(this.name)
            this.score = score
        }
        Student.prototype = Object.create(Person.prototype)
        Student.prototype.constructor = Student
        Student.prototype.sleep = function() {
            console.log('睡觉');
        }

        var s1 = new Student('张三', 100)
        s1.sayName() // 张三
        console.log(Student.prototype.__proto__ == Person.prototype);
    </script>
</body>

</html>